home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / xmtool.pro < prev    next >
Text File  |  1997-07-08  |  4KB  |  144 lines

  1. ; $Id: xmtool.pro,v 1.8 1997/01/15 16:48:19 ali Exp $
  2. ;
  3. ; Copyright (c) 1991-1997, Research Systems, Inc.  All rights reserved.
  4. ;    Unauthorized reproduction prohibited.
  5.  
  6. PRO UpdateXMToolList, widList
  7.  
  8.   COMMON MANAGED, ids, names, outermodal
  9.  
  10.   ; Make sure XManager's version of the list is up to date
  11.   ValidateManagedWidgets
  12.   
  13.   ; put some error handling around our calls to WIDGET_CONTROL since
  14.   ; our widget could have gone away behind our backs
  15.   err = 0
  16.   catch, err
  17.   if (err EQ 0) THEN BEGIN
  18.     ; get our list of widgets
  19.     WIDGET_CONTROL, widList, GET_UVALUE=list
  20.     selectedWid = WIDGET_INFO(widList, /LIST_SELECT)
  21.   
  22.     ; are the lists different?
  23.     listSize = size(list)
  24.     namesSize = size(names)
  25.     IF (namesSize[N_ELEMENTS( namesSize)-2] EQ 7) THEN BEGIN
  26.         IF((listSize[0] NE namesSize[0]) OR (listSize[1] NE namesSize[1]) OR $
  27.           (listSize[2] NE namesSize[2]) OR ((where(list NE names))[0] NE -1)) $
  28.           THEN $
  29.           WIDGET_CONTROL, widList, SET_UVALUE=names, SET_VALUE=names, $
  30.           SET_LIST_SELECT=selectedWid
  31.     ENDIF
  32.   ENDIF
  33. END
  34.  
  35. PRO XManTool_event, event
  36.  
  37.   COMMON MANAGED, ids, names, outermodal
  38.  
  39.   WIDGET_CONTROL, event.id, GET_UVALUE = evntval
  40.   widList = WIDGET_INFO(event.top, /CHILD)
  41.   
  42.   selectedWid = WIDGET_INFO(widList, /LIST_SELECT)
  43.  
  44.   ; Handle events for everything but the list widget (the list widget's
  45.   ; uvalue is an array, so we can't use it in the case statement)
  46.   IF (event.id NE widList) THEN BEGIN
  47.     CASE evntval OF
  48.       'KILLWID' : BEGIN
  49.     IF (selectedWid NE -1) THEN $
  50.       WIDGET_CONTROL, ids[selectedWid], /DESTROY
  51.       END
  52.  
  53.       'SHOWWID' : BEGIN
  54.     IF (selectedWid NE -1) THEN $
  55.       WIDGET_CONTROL, ids[selectedwid], /SHOW
  56.       END
  57.  
  58.       'UPDATE' : BEGIN
  59.     WIDGET_CONTROL, event.id, TIMER = 1
  60.       END
  61.       ELSE:
  62.     ENDCASE
  63.   ENDIF
  64.  
  65.   ; Make sure the list is up to date
  66.   UpdateXMToolList, widList
  67.  
  68. END
  69.  
  70.  
  71. ;-----------------------------------------------------------------------------
  72. ;+
  73. ; NAME:
  74. ;    XMTOOL
  75. ;
  76. ; PURPOSE:
  77. ;    Provide a tool for viewing Widgets currently being managed by the 
  78. ;    XMANAGER.
  79. ;
  80. ; CATEGORY:
  81. ;    Widgets.
  82. ;
  83. ; CALLING SEQUENCE:
  84. ;    XMTOOL
  85. ;
  86. ; KEYWORD PARAMETERS:
  87. ;    GROUP:    The widget ID of the group leader that the XMANAGERTOOL 
  88. ;        is to live under.  If the group is destroyed, the 
  89. ;        XMANAGERTOOL is also destroyed.
  90. ;
  91. ; SIDE EFFECTS:
  92. ;    This procedure creates a widget that has the ability to destroy other 
  93. ;    widgets being managed by the XManager.
  94. ;
  95. ; RESTRICTIONS:
  96. ;    Only one instance of the XMANAGERTOOL can run at one time.
  97. ;
  98. ; PROCEDURE:
  99. ;    Initiate the widget and then let the timer routine update the
  100. ;    lists as the widgets being managed by the XMANAGER are changed.
  101. ;
  102. ; MODIFICATION HISTORY:
  103. ;    Written by Steve Richards, Dec, 1990.
  104. ;    SMR - 6/93    Modified the routine to work with a timer instead
  105. ;            of the obsolete background tasks.
  106. ;-
  107.  
  108. PRO XMTool, GROUP = GROUP
  109.  
  110.   COMMON MANAGED
  111.  
  112.   IF (XRegistered('XManagerTool')) THEN RETURN
  113.  
  114.   toolbase = WIDGET_BASE(TITLE = 'Managed Widgets', $
  115.              /COLUMN, UVALUE = 'UPDATE', TLB_FRAME_ATTR=1)
  116.  
  117.   widList = WIDGET_LIST(toolbase, VALUE = 'XmanagerTool', $
  118.               UVALUE = 'XmanagerTool', YSIZE = 10)
  119.   WIDGET_CONTROL, widList, SET_LIST_SELECT=0
  120.  
  121.   litcontbase = WIDGET_BASE(toolbase, /ROW, /GRID_LAYOUT)
  122.   showster = WIDGET_BUTTON(litcontbase, VALUE = 'Bring To Front', $
  123.                UVALUE = 'SHOWWID')
  124.   killer = WIDGET_BUTTON(litcontbase, VALUE = 'Kill Widget', $
  125.              UVALUE = 'KILLWID')
  126.  
  127.   WIDGET_CONTROL, toolbase, /REALIZE
  128.  
  129.   ; If XMANAGER is not yet compiled, compile it because we rely on internal
  130.   ; support routines from that module. We can't indescriminately just
  131.   ; compile because that would kill a running XMANAGER if one is present.
  132.   ; We rely on the MANAGED common block variable outerModal to be defined
  133.   ; only when XMANAGER runs to detect which is the case.
  134.   if (n_elements(outerModal) eq 0) then RESOLVE_ROUTINE,'XMANAGER'
  135.  
  136.   UpdateXMToolList, widList
  137.   WIDGET_CONTROL, toolbase, TIMER = 1
  138.  
  139.   Xmanager, 'XManagerTool', toolbase, EVENT_HANDLER = 'XManTool_event', $
  140.         GROUP_LEADER = GROUP, /NO_BLOCK
  141.  
  142. END
  143.  
  144.